1 using System;
2 using
System.Collections.Generic;
3 using
System.ComponentModel;
4 using
System.Data;
5 using
System.Drawing;
6 using
System.Linq;
7 using
System.Text;
8 using
System.Windows.Forms;
9 using
System.Data.SqlClient;
10 using
Telerik.WinControls;
11 using
Telerik.Data;
12 using
QuanLyNhanSu.Class;
13
14 namespace
QuanLyNhanSu
15 {
16     
public partial class frmDMLoaiHD : RadForm
17     {
18         clsdmhd c =
new clsdmhd();
19         
//bien luu tru trang thai them hay sua
20         
int k = 0;
21         
public frmDMLoaiHD()
22         {
23             InitializeComponent();
24             c.laydl(
"tbl_LoaiHD");
25             
//lấy dữ liệu ra textbox
26             txtmahd.DataBindings.Add(
"text", c.ds, "tbl_loaihd.maloaiHD");
27             txttenloai.DataBindings.Add(
"text", c.ds, "tbl_loaihd.TenLoaiHD");
28             dgv_DMHD.DataSource = c.ds;
29             dgv_DMHD.DataMember =
"tbl_LoaiHD";
30
31             dgv_DMHD.Columns[
0].HeaderText = "Mã hợp đồng";
32             dgv_DMHD.Columns[
1].HeaderText = "Lọai hợp đồng";
33
34         }
35
36         
public void setbutton(bool b)
37         {
38             cmdCapnhat.Enabled = b;
39             cmdthem.Enabled = b;
40             cmdthoat.Enabled = b;
41             cmdxoa.Enabled = b;
42             cmdluu.Enabled = !b;
43         }
44
45         
private void frmDMLoaiHD_Load(object sender, EventArgs e)
46         {
47             setbutton(
true);
48         }
49         
private void txtmahd_KeyPress(object sender, KeyPressEventArgs e)
50         {
51             
if (!Char.IsNumber(e.KeyChar))
52             {
53                 RadMessageBox.Show(
"\nBạn phải nhập số !\n", "Thông báo", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
54                 txtmahd.Text =
"";
55                 txtmahd.Focus();
56             }
57         }
58
59         
private void cmdthoat_Click(object sender, EventArgs e)
60         {
61             Close();
62         }
63
64         
private void cmdthem_Click(object sender, EventArgs e)
65         {
66             txtmahd.Text =
"";
67             txttenloai.Text =
"";
68             txtmahd.ReadOnly =
false;
69             txttenloai.ReadOnly =
false;
70             txtmahd.Focus();
71             setbutton(
false);
72             k =
1;
73         }
74
75         
private void cmdCapnhat_Click(object sender, EventArgs e)
76         {
77             
if (dgv_DMHD.SelectedRows.Count == 0)
78             {
79                 RadMessageBox.Show(
"\nBạn phải chọn dòng để cập nhật !\n", "Thông Báo", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
80                 
return;
81             }
82             
else
83             {
84                 txttenloai.ReadOnly =
false;
85                 txttenloai.Focus();
86                 setbutton(
false);
87                 k =
2;
88             }
89         }
90
91         
private void cmdxoa_Click(object sender, EventArgs e)
92         {
93             
if (dgv_DMHD.SelectedRows.Count == 0)
94             {
95                 RadMessageBox.Show(
"\nBạn phải chọn dòng để xóa !\n", "Thông Báo", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
96                 
return;
97             }
98             
else
99             {
100                 DialogResult rs = RadMessageBox.Show(
"\nBạn thật sự muốn xóa thông tin này không?\n", "Thông Báo", MessageBoxButtons.YesNo, RadMessageIcon.Question);
101                 
if (rs == DialogResult.Yes)
102                 {
103                     c.xoa(
"tbl_LoaiHD", int.Parse(txtmahd.Text.Trim()), "Maloaihd");
104                     c.laydl(
"tbl_loaihd");
105
106                 }
107             }
108         }
109
110         
private void cmdluu_Click(object sender, EventArgs e)
111         {
112             DialogResult rs = RadMessageBox.Show(
"\nBạn thật sự muốn lưu thông tin này không ?\n", "Thông Báo", MessageBoxButtons.YesNo, RadMessageIcon.Question);
113             
if (rs == DialogResult.Yes)
114             {
115                 
if (k == 1)
116                 {
117                     
if (txtmahd.Text == "" || txttenloai.Text == "")
118                     {
119                         RadMessageBox.Show(
this, "\nBạn phải nhập đầy đủ thông tin vào !\n", "Thông báo", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
120                         
return;
121                     }
122                     
else
123                     {
124                         c.them(
"tbl_LoaiHD", int.Parse(txtmahd.Text.Trim()), txttenloai.Text.Trim());
125                     }
126                 }
127                 
else if (k == 2)
128                 {
129                     
if (txtmahd.Text == "" || txttenloai.Text == "")
130                     {
131                         RadMessageBox.Show(
this, "\nBạn phải nhập đầy đủ thông tin vào !\n", "Thông báo", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
132                         
return;
133                     }
134                     
else
135                     {
136
137                         c.sua(
"tbl_loaihd", int.Parse(txtmahd.Text.Trim()), txttenloai.Text.Trim(), "maloaihd", "tenloaihd");
138                     }
139                 }
140             }
141             c.laydl(
"tbl_loaihd");
142             txtmahd.ReadOnly =
true;
143             txttenloai.ReadOnly =
true;
144             k =
0;
145             setbutton(
true);
146         }
147     }
148 }
149                     



Quản lý nhân sự công ty bằng c# _ full source code 60.402 lượt xem

Gõ tìm kiếm nhanh...